#include<iostream>
#include<vector>
using namespace std;

int search(int arr[], int size, int target)
{
	int left = 0;
	int right = size -1;
	while (left <= right)
	{
		int middle = (left + right) / 2;
		if (arr[middle] > target)
		{
			right = middle - 1;

		}
		else if (arr[middle] < target) {
			left = middle + 1;
		}
		else
		{
			return middle;
		}
	}
}
int main()
{
	int arr[5] = { 1,2,3,4,5 };
	int index = 0;
	index = search(arr, 5, 5);

	cout << "The index is:" << index << endl;
	return 0;
}